
#include <ros/ros.h>
#include <nodelet/nodelet.h>
#include <image_transport/subscriber.h>
#include <image_transport/image_transport.h>

#include <cv_bridge/CvBridge.h>
#include <opencv2/highgui/highgui.hpp>
//#include "window_thread.h"

#include <boost/thread.hpp>
#include <boost/format.hpp>

#ifdef HAVE_GTK
#include <gtk/gtk.h>
#endif

#include "MainWindow.cpp"
#include "Viewer.cpp"
#include "Arrow.cpp"
#include "Infos.cpp"
#include "JoystickControler.cpp"
#include "KeyboardControler.cpp"

class App {
public:
	App();
	virtual ~App();

	MainWindow* pWin;
	Viewer* pViewer;
	Arrow* pArrow;
	Infos* pInfos;
	JoystickControler* pJoy;
	KeyboardControler* pKey;



};

int main(int argc, char **argv)
{
	// Enregistrer la 'pplication ROS
	//
	ros::init(argc, argv, "UniceBot Controler", ros::init_options::AnonymousName);
	ROS_WARN("##Je demarre");

	// Obtenir une reference sur l'aplication elle même auprés du noyau ROS
	//
	ros::NodeHandle n;
	ros::NodeHandle nh("~");

	// Command line argument parsing
	// First positional argument is the transport type
	std::string transport = "raw";
	for (int i = 0; i < argc; ++i)
	{
		if (argv[i][0] != '-')
		{
		  transport = argv[i];
		  break;
		}
	}

	return 0;
} //main

App::App() {
	// Instancier la fenetre principale
		//
		MainWindow* pWin = new MainWindow();


		// Instancier le viewer
		//
		Viewer* pViewer = new Viewer();

		// Viewer: S'abboner à la publication "/image" avec le viewer en callback
		//
		image_transport::ImageTransport it(nh);
		//sub_ = it.subscribe(topic, 1, &imageCb, this, transport);
		pWin->sub_ = it.subscribe("/image", 3, &pViewer->callBack());


		// Instancer la fleche
		//
		Arrow* pArrow = new Arrow();

		// Instancier les infos
		//
		Infos* pInfos =new Infos();

		// Instancier le Joystick Controler
		//
		JoystickControler* pJoy = new JoystickControler();

		// Instancier le KeyboardControler
		//
		KeyboardControler* pKey = new KeyboardControler();


		// Boucle evenementielle ROS
		/////////////////////////////////////////////
		ROS_WARN("####spin");
		ros::spin();

}// App::App()



